package com.lollipop.shardingjdbc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lollipop.shardingjdbc.entity.ShardingUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: J.K
 * @Date: 2021-09-17 08:35
 * @Description:
 */
@Component
@Mapper
public interface ShardingUserMapper extends BaseMapper<ShardingUser> {
    /**
     * 查询所有
     *
     * @return
     */
    @Select("SELECT * FROM sharding_user")
    List<ShardingUser> userList();

    /**
     * 分页查询
     *
     * @return
     */
    @Select("SELECT * FROM sharding_user limit 0,2")
    List<ShardingUser> userListPage();

    /**
     * user_0 2,4 user_1 1,3
     * 2 4  1 3 limit 2 24
     */

    /**
     * 排序
     *
     * @return
     */
    @Select("SELECT * FROM sharding_user order by id desc ")
    List<ShardingUser> userOrderBy();

    /**
     * get by id
     *
     * @return
     */
    @Select("SELECT * FROM sharding_user where id =#{id} ")
    List<ShardingUser> getByUserId(Long id);
}
